<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>公告管理</title>
    <jsp:include page="../../import.jsp" flush="true"/>
    <script src="<%=path %>/resource/lib/ueditor/ueditor.config.js" charset="utf-8" type="text/javascript"></script>
    <script src="<%=path %>/resource/lib/ueditor/ueditor.all.min.js" charset="utf-8" type="text/javascript"></script>
    <script src="<%=path %>/resource/lib/ueditor/lang/zh-cn/zh-cn.js" charset="utf-8" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            initForm();
            saveEvent();
        });

        //初始化表单
        function initForm() {
            $("#formSet1").ligerForm({
                validate: true
            });
        }

        //保存事件
        function saveEvent() {
            $("#saveBtn1").click(function (event) {
                var form = liger.get("formSet1");
                if (!form.valid()) {
                    top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO, SQ_type: "warning"});
                    return false; //验证不通过，不执行以下代码
                }
                var data = form.getData();

                var notice_Content=UE.getEditor('editor').getContent();
                data.notice_Content=notice_Content;
                var url = '<%=path%>/carloan/odrnoticeinfo/modify.do';
                var wait_dialog;
                $.ajax({
                    type: 'post',
                    dataType: 'json',
                    data: data,
                    url: url,
                    beforeSend: function () {
                        wait_dialog = $.ligerDialog.SQalert({
                            content: LogUtils.LOG_CMM_DATA_LOADING,
                            SQ_type: "waitting"
                        });
                    },
                    success: function (msg) {
                        wait_dialog.close();
                        if (msg.success == 1) {
                            top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                            var callback = GET_W2Wcallback();
                            callback();
                            Remove_navTab();
                        } else {
                            top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                        }
                    }
                });
            });
        }
    </script>
</head>
<body class="iframeBody">
<div class="Wrapper">
    <form id="formSet1">
        <table class="layout2col1">
            <tbody>
            <tr>
                <td valign="top">
                    <div class="fieldset1 tabel_col clearFix">

                        <div class="fieldBox col_100_auto">
                            <div class="label">公告标题&nbsp;<span style="color: red">*</span></div>
                            <div class="field">
                                <input name="title" id="title" type="text" class="ui-textbox"
                                       value="${noticeInfoVO.title}" validate="{required:true}" maxlength="50">
                            </div>
                        </div>
                        <div class="fieldBox col_100_auto">
                            <div class="label">公告标签&nbsp;<span style="color: red"></span></div>
                            <div class="field">
                                <select id="option" name="label">
                                    <option  value=" " selected="selected">--请选择--</option>
                                    <option  value="tongzhi"  <c:if test="${noticeInfoVO.label=='tongzhi'}">selected</c:if>>通知</option>
                                    <option  value ="zhongyao" <c:if test="${noticeInfoVO.label=='zhongyao'}">selected</c:if>>重要</option>
                                    <option  value ="zhengce" <c:if test="${noticeInfoVO.label=='zhengce'}">selected</c:if>>政策</option>
                                </select>
                            </div>
                        </div>
                        <div class="fieldBox col_100_auto">
                            <div class="label">公告描述&nbsp;<span style="color: red">*</span></div>
                            <div class="field">
                                <input name="noticeDesc" id="noticeDesc" type="text" class="ui-textbox"
                                       value="${noticeInfoVO.pictUrl}" validate="{required:true}" maxlength="100" >
                            </div>
                        </div>
                        <div class="fieldBox col_100_auto">
                            <div class="label">上传图片&nbsp;<span style="color: red"></span></div>
                            <div class="field">
                                <jsp:include page="../../system/sysUlFilesRec/sysSysUlFilesRecUpload.jsp" flush="true">
                                    <jsp:param name="fileNum" value="1"/>
                                    <jsp:param name="filePath" value="carloan/wechatpictrec"/>
                                </jsp:include>
                            </div>
                        </div>
                        <div class="fieldBox col_100_auto">
                            <div class="label">图片地址&nbsp;<span style="color: red"></span></div>
                            <div class="field">
                                <input name="pictUrl" id="imgPth" type="text" class="ui-textbox" ligerui="width:700"
                                       value=""  disabled="disabled">
                            </div>
                        </div>
                    </div>
                    <div id="editor" style="height:360px">
                        公告内容:
                        <script type="text/javascript" charset="utf-8">
                            UE.getEditor('editor');
                        </script>
                    </div>
                    <div id="btnsBox" class="btnsBox">
                        <input name="noticeId" id="noticeId" type="text" style="display: none;" value="${noticeInfoVO.id}"/>
                        <span id="saveBtn1" class="sq-button sq-button-round">保存</span>
                        <input type="reset" id="resetBtn" class="l-button l-button-reset Hide">
                    </div>
                </td>
            </tr>
            </tbody>
        </table>
    </form>
</div>
<div class="clearLine"></div>
</body>
<script type="text/javascript">
    //实例化编辑器
    // 建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
    var ue = UE.getEditor('editor');
    var htmlStr = '${noticeInfoVO.noticeContent}';
    console.log(htmlStr);
    ue.ready(function() {
        ue.setContent(htmlStr, false);
    });


    var serverpath = '${serverpath}';

    //上传回调方法必须写在上传插件之后
    function uploadCallback(_data) {
        if (_data && _data.length > 0) {
            $("#imgPth").val(serverpath + _data[0].filePath);
            var suffix = /\.[^\.]+/.exec(_data[0].fileNm).toUpperCase();
            if(suffix!="BMP"&&suffix!="JPG"&&suffix!="JPEG"&&suffix!="PNG"&&suffix!="GIF") {
                top.$.ligerDialog.SQalert({content: "请上传图片（格式BMP、JPG、JPEG、PNG、GIF等）!", SQ_type: "error"});
            }
        }
    }
    $("#option").val(${noticeInfoVO.label });
</script>
</html>